import { UploadUtils } from "./TCDNUploadFlowPorts";
import { Time } from "./time";
import { UploadAbility } from "./uploadHZYX";
import { WechatCI } from "./wechatCompile";
import { Zip } from "./zip";
import * as fs from "fs"

export class UnityPack {
    public static async packWindows() {
        console.log(process.cwd())
        let packName = Time.getTodayDate();
        await Zip.compressFunc("../../tmp/MEEC", `../../tmp/${packName}.zip`);

        UploadAbility.setUploadDefaultConfig();
        UploadUtils.uploadSingleFile(`../../tmp/${packName}.zip`, `${packName}.zip`)
            .then((downloadUrl: string) => {
                WechatCI.robotMsg(WechatCI.DEFAULT_GROUP_ID, "unity windows打包结束,下载链接 " + downloadUrl)
            })
            .catch((e => {
                console.log(e)
            }));
    }

    public static async packAndroid() {
        console.log(process.cwd())
        let packName = Time.getTodayDate();

        //重命名文件
        fs.rename('../../tmp/MEEC/MEEC_MASTER.apk', `../../tmp/MEEC/${packName}.apk`, (err) => {
            console.log(err);
        })

        UploadAbility.setUploadDefaultConfig();
        UploadUtils.uploadSingleFile(`../../tmp/MEEC/${packName}.apk`, `${packName}.apk`)
            .then((downloadUrl: string) => {
                WechatCI.robotMsg(WechatCI.DEFAULT_GROUP_ID, "unity Android打包结束,下载链接 " + downloadUrl)
            })
            .catch((e => {
                console.log(e)
            }));
    }

}